package com.ruoyi.web.controller.travel;


import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.travel.domain.TravelSchedule;
import com.ruoyi.travel.service.ITravelScheduleService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

@RestController
@RequestMapping("/travel/schedule")
public class TravelScheduleController extends BaseController
{
    @Autowired
    private ITravelScheduleService travelScheduleService;

    /**
     * 查询行程管理列表
     */
    @PreAuthorize("@ss.hasPermi('travel:schedule:list')")
    @GetMapping("/list")
    public TableDataInfo list(TravelSchedule travelSchedule)
    {
        startPage();
        List<TravelSchedule> list = travelScheduleService.selectTravelScheduleList(travelSchedule);
        return getDataTable(list);
    }

    /**
     * 获取行程管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('travel:schedule:query')")
    @GetMapping(value = "/{scheduleId}")
    public AjaxResult getInfo(@PathVariable("scheduleId") Long scheduleId)
    {
        return success(travelScheduleService.selectTravelScheduleByScheduleId(scheduleId));
    }

    /**
     * 新增行程管理
     */
    @PreAuthorize("@ss.hasPermi('travel:schedule:add')")
    @Log(title = "行程管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TravelSchedule travelSchedule)
    {

        travelScheduleService.insertTravelSchedule(travelSchedule);
        return success(travelSchedule);
    }
    /**
     * 咨询列表
     */
    @PreAuthorize("@ss.hasPermi('travel:schedule:add')")
    @Log(title = "行程管理", businessType = BusinessType.INSERT)
    @GetMapping("/consultByDesignerList")
    public TableDataInfo consultList(TravelSchedule travelSchedule)
    {
        System.out.println(travelSchedule.getTravelConsult().getDesignerId());
        startPage();
        List<TravelSchedule> list = travelScheduleService.selectConsultByDesignerId(travelSchedule);
        System.out.println(list);
        return getDataTable(list);
    }
    /**
     * 修改行程管理
     */
    @PreAuthorize("@ss.hasPermi('travel:schedule:edit')")
    @Log(title = "行程管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TravelSchedule travelSchedule)
    {
        return toAjax(travelScheduleService.updateTravelSchedule(travelSchedule));
    }

    /**
     * 删除行程管理
     */
    @PreAuthorize("@ss.hasPermi('travel:schedule:remove')")
    @Log(title = "行程管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{scheduleIds}")
    public AjaxResult remove(@PathVariable Long[] scheduleIds)
    {
        return toAjax(travelScheduleService.deleteTravelScheduleByScheduleIds(scheduleIds));
    }
}
